<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>通过已打开的文件指针取得文件信息</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fseek.html">fseek</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ftell.html">ftell</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="function.fstat" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">fstat</h1>
  <p class="verinfo">(PHP 4, PHP 5)</p><p class="refpurpose"><span class="refname">fstat</span> &mdash; <span class="dc-title">通过已打开的文件指针取得文件信息</span></p>

 </div>
 
 <div class="refsect1 description" id="refsect1-function.fstat-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="type">array</span> <span class="methodname"><strong>fstat</strong></span>
    ( <span class="methodparam"><span class="type">resource</span> <code class="parameter">$handle</code></span>
   )</div>

  <p class="para rdfs-comment">
   获取由文件指针 <em><code class="parameter">handle</code></em>
   所打开文件的统计信息。本函数和 <span class="function"><a href="function.stat.html" class="function">stat()</a></span>
   函数相似，除了它是作用于已打开的文件指针而不是文件名。
  </p>
 </div>


 <div class="refsect1 parameters" id="refsect1-function.fstat-parameters">
  <h3 class="title">参数</h3>
  <p class="para">
   <dl>

    
     <dt>
<em><code class="parameter">handle</code></em></dt>

     <dd>

      <p class="para">文件系统指针，是典型地由
<span class="function"><a href="function.fopen.html" class="function">fopen()</a></span> 创建的 <span class="type"><a href="language.types.resource.html" class="type resource">resource</a></span>(资源)。</p>
     </dd>

    
   </dl>

  </p>
 </div>


 <div class="refsect1 returnvalues" id="refsect1-function.fstat-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回一个数组具有该文件的统计信息，该数组的格式详细说明于手册中
   <span class="function"><a href="function.stat.html" class="function">stat()</a></span> 页面里。
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-function.fstat-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-2329">
    <p><strong>Example #1 <span class="function"><strong>fstat()</strong></span> 例子</strong></p>
    <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br /></span><span style="color: #FF8000">//&nbsp;打开文件<br /></span><span style="color: #0000BB">$fp&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fopen</span><span style="color: #007700">(</span><span style="color: #DD0000">"/etc/passwd"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"r"</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;取得统计信息<br /></span><span style="color: #0000BB">$fstat&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">fstat</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;关闭文件<br /></span><span style="color: #0000BB">fclose</span><span style="color: #007700">(</span><span style="color: #0000BB">$fp</span><span style="color: #007700">);<br /><br /></span><span style="color: #FF8000">//&nbsp;只显示关联数组部分<br /></span><span style="color: #0000BB">print_r</span><span style="color: #007700">(</span><span style="color: #0000BB">array_slice</span><span style="color: #007700">(</span><span style="color: #0000BB">$fstat</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">13</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程的输出类似于：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Array
(
    [dev] =&gt; 771
    [ino] =&gt; 488704
    [mode] =&gt; 33188
    [nlink] =&gt; 1
    [uid] =&gt; 0
    [gid] =&gt; 0
    [rdev] =&gt; 0
    [size] =&gt; 1114
    [atime] =&gt; 1061067181
    [mtime] =&gt; 1056136526
    [ctime] =&gt; 1056136526
    [blksize] =&gt; 4096
    [blocks] =&gt; 8
)
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 notes" id="refsect1-function.fstat-notes">
  <h3 class="title">注释</h3>
  <blockquote class="note"><p><strong class="note">Note</strong>: <span class="simpara">此函数不能作用于<a href="features.remote-files.html" class="link">远程文件</a>，被检查的文件必须是可通过服务器的文件系统访问的。</span></p></blockquote>
 </div>

</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="function.fseek.html">fseek</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="function.ftell.html">ftell</a></div>
 <div class="up"><a href="ref.filesystem.html">Filesystem 函数</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
